﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T12OOP
{
    class Contact
    {
        private string name;
        private string homePhone;
        private string mobilePhone;
        private string busiPhone;
        private string fax;




        //只读属性
        public string Name
        {
            get { return name; }
        }

        //索引方式属性
        public string this[string type]
        {
            get
            {
                switch (type)
                {
                    case "moblie": return mobilePhone;
                    case "home": return homePhone;
                    case "business": return busiPhone;
                    case "fax": return fax;
                    default: return "none";
                }
            }
            set
            {
                switch (type)
                {
                    case "mobile": mobilePhone = value; break;
                    case "home": homePhone = value; break;
                    case "business": busiPhone = value; break;
                    case "fax": fax = value; break;

                }
            }
        }

        public Contact(string name)
        {
            this.name = name;
        }


            public override string ToString()
        {
            return string.Format("联系人信息：[{0}][{1}][{2}][{3}][{4}]",
                name,homePhone ,mobilePhone, busiPhone ,fax
                );
        }
   
    }
}
